/**
 * Description: 消息（暂无使用）
 *
 * Created by hrx on 2023/9/18
 */
import { ElMessage, ElNotification } from 'element-plus'
import type { EpPropMergeType } from "element-plus/es/utils";
let showingMessage = false;

interface ICodeMessage {
  [key: number] : string
}


export const codeMessage: ICodeMessage = {
	401: '用户未认证,请先登录',
	500: '服务端开小差了，请稍后',
	502: '服务端开小差了，请稍后',
	503: '服务端开小差了，请稍后',
	504: '服务端开小差了，请稍后'
}

export function showNotify(content: string, type?: EpPropMergeType<StringConstructor, "" | "success" | "warning" | "info" | "error", unknown>): void {
	if (showingMessage) {
		return;
	}
	showingMessage = true;
  ElNotification({
    title: '提示',
		message: content,
		type: type,
		duration: 2000,
		showClose: true,
    customClass: 'notification',
		onClose: function () {
			showingMessage = false;
		}
	})
}

export function
showMessage (content: string, type?: EpPropMergeType<StringConstructor, "success" | "warning" | "info" | "error", unknown>): void {
	if (showingMessage) {
		return;
	}
	showingMessage = true;
  ElMessage({
		message: content,
		type: type,
		showClose: true,
		duration: 2000,
		onClose: function () {
			showingMessage = false;
		}
	})
}
